#include "TestUI.h"
#include "string.h"
#include "math.h"
#include "main.h"

//--------定义页面对象
TitlePage main_page;
    RaderPicPage logo_page;
    ListPage setting_page;
        ListPage udisk_setting_page;
        ListPage ui_setting_page;
    RaderPicPage g_volumn_page;
    RaderPicPage dictionary_page;
    RaderPicPage emotion_page;
    ListPage about_page;
        RadioPage about_wououi_page; //这两个相关页使用单选项RadioPage类型只是为了展示单选项页面而已
        RadioPage about_page_version_page;
//--------定义每个页面需要的一些参数
//部分页面内选项个数
#define MAIN_PAGE_NUM           6   
#define LOGO_PAGE_NUM           4  
#define SETTING_PAGE_NUM        3   
#define UI_SETTING_PAGE_NUM     13   
#define UDISK_SETTING_PAGE_NUM  3   
#define ABOUT_PAGE_NUM          3   
#define ABOUT_WOUOUI_PAGE_NUM   9   
#define ABOUT_PAGEVERSION_NUM   8   

//定义部分页面选项
//********main页面的选项
Option mian_option_array[MAIN_PAGE_NUM] = 
{///{ order,max,min,step,int_val,text,} //option的成员顺序，但对单纯title的页面来说，只有text需要赋值
    {.text = "- Logo"},  //前两个字符是前缀，不显示，用于标识一般选项(-),二值选项(+),数值弹窗(~),确认弹窗($)
    {.text = "- Setting"},
    {.text = "- Volumn"},
    {.text = "- File"},
    {.text = "- Emoji"},
    {.text = "- About"},
};
//main页面的图标
Icon main_icon_array[MAIN_PAGE_NUM] = 
{
    [0]  = {0xFC,0xFE,0xFF,0x3F,0x1F,0x0F,0x07,0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
            0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x07,0x0F,0x1F,0x3F,0xFF,0xFE,0xFC,0xFF,0x01,
            0x00,0x00,0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0xFC,
            0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF0,0xC0,0x00,
            0x00,0x00,0x03,0x07,0x0F,0x1F,0x3E,0x3C,0x3C,0x3C,0x1E,0x1F,0x0F,0x03,0x00,0x00,
            0x1F,0x3F,0x3F,0x1F,0x00,0x00,0x00,0xC0,0xF0,0xFF,0xCF,0xDF,0xFF,0xFF,0xFE,0xFC,
            0xF8,0xF8,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,
            0xF8,0xF8,0xFC,0xFE,0xFF,0xFF,0xDF,0xCF}, //logo
    [1]  = {0xFC,0xFE,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x83,0x81,0x01,0x01,0x81,0xE1,0xE1,0xE1,
            0xE1,0x81,0x01,0x81,0x81,0x83,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFE,0xFC,0xFF,0x01,
            0x00,0x00,0x00,0xE0,0xE0,0xF3,0xFF,0xFF,0x3F,0x0F,0x07,0x07,0x03,0x03,0x07,0x07,
            0x0F,0x3F,0xFF,0xFF,0xF7,0xE0,0xE0,0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x80,0x00,
            0x00,0x01,0x01,0x3B,0x7F,0x7F,0x7F,0x3C,0x78,0xF8,0xF0,0xF0,0xF8,0x78,0x3C,0x3F,
            0x7F,0x7F,0x33,0x01,0x01,0x00,0x00,0x80,0xE0,0xFF,0xCF,0xDF,0xFF,0xFF,0xFE,0xFC,
            0xF8,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE1,0xE1,0xE1,0xE1,0xE0,0xE0,0xE0,0xE0,0xF0,
            0xF0,0xF8,0xFC,0xFC,0xFF,0xFF,0xDF,0xCF}, // Setting
    [2]  = {0x00,0xFC,0xFE,0x1E,0x1E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x86,0x06,
            0x06,0xC6,0x86,0x86,0x06,0x06,0x06,0x06,0x06,0x1E,0x1E,0xFE,0xFC,0x00,0x00,0xFF,
            0xFF,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0xFC,0xFC,0xFE,0xFF,0xFF,0x00,0x00,0xF1,
            0xE1,0xE1,0x03,0x0F,0xFC,0xF0,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,
            0x00,0x00,0x03,0x03,0x03,0x03,0x0F,0x0F,0x1F,0x3F,0x7F,0x00,0x00,0xC3,0x61,0x61,
            0x70,0x3C,0x1F,0x07,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x0F,0x1F,0x1E,0x1E,0x18,
            0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
            0x18,0x18,0x18,0x1E,0x1E,0x1F,0x0F,0x00},/*"volumn.bmp",0*/
    [3]  = {0x00,0xE0,0xF8,0x18,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
            0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x18,0xF8,0xE0,0x00,0x00,0xFF,
            0xFF,0x00,0x00,0x00,0x00,0xCC,0xCE,0xCE,0xCE,0xCE,0xCE,0xCE,0xCC,0xC8,0xC8,0xC8,
            0xC8,0xC8,0xC8,0xC0,0xC0,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,
            0x00,0x00,0x00,0x07,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
            0x1F,0x0F,0x07,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x07,0x06,0x1C,0x18,
            0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
            0x18,0x18,0x18,0x1C,0x06,0x07,0x01,0x00,}, //dictionary
    [4] = {0xFC,0xFE,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
            0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFE,0xFC,0xFF,0xFF,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
            0x00,0x00,0x00,0x00,0x20,0x60,0x40,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x40,
            0x60,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x0F,0x1F,0x30,0x30,0x30,0x30,
            0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
            0x30,0x30,0x30,0x30,0x30,0x30,0x1F,0x0F}, //表情
    [5]  = {0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x07,
            0x07,0x0F,0x0F,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xFF,0xFF,
            0xFF,0x3F,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xEE,0xE6,0x66,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
            0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1F,0x1F,0x08,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x60,0xF0,0xFF,0xFF,0xFF,0xFF,0xCF,0xDF,0xFF,0xFF,0xFF,0xFF,
            0xFF,0xFF,0xFF,0xFE,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
            0xF8,0xF8,0xF8,0xF8,0xFF,0xFF,0xDF,0xCF} //about
};

//LOGO页面的参数
const uint8_t logo_wouo_pic[] = {0x00,0x00,0xF8,0xF0,0x80,0x00,0x00,0x00,0xE0,0xFC,0xE0,0x00,0x00,0x00,0x00,0xF0,
                                0xFC,0x04,0x18,0x30,0x70,0xE0,0xC0,0xE0,0xF0,0xF8,0x38,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x70,0x70,0xE0,0xC0,0xE0,0xF0,0x78,0x18,0x00,
                                0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0xF8,0x3F,0x03,0x01,0x1F,0x7E,0xF0,0xE0,0xFE,
                                0x7F,0x01,0x00,0x00,0xF8,0x8E,0x83,0x81,0xC1,0x41,0x71,0x3F,0x00,0x00,0x7F,0xC0,
                                0xC0,0xC0,0x60,0x30,0x7E,0xFF,0x00,0x00,0xFC,0x8E,0x83,0x81,0xC1,0x61,0x3B,0x1F,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
                                0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00}; //49*20
const uint8_t logo_ui_pic[] = {0x00,0x00,0x00,0xF0,0xFC,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFE,
                                0xFC,0x00,0x00,0x0C,0x0C,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x7F,
                                0xC0,0x80,0x80,0x80,0xC0,0xE0,0x70,0x38,0x1C,0xFF,0xFF,0xF8,0x00,0x00,0x80,0xC0,
                                0xFF,0x9F,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,
                                0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
                                0x00}; // 27*20
const uint8_t logo_page_pic[] = {0x00,0x00,0x00,0xF0,0xFC,0x0C,0x0C,0x0C,0x98,0xF0,0x00,0x00,0x00,0x00,0x80,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x80,0x80,0x80,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xCF,0x0C,0x0E,0x06,0x03,0x03,0x00,0x18,
                                0x2E,0x21,0x21,0x31,0x1E,0x3C,0x20,0x0C,0x1F,0x11,0x10,0x90,0xFF,0x00,0x1C,0x3E,
                                0x65,0x65,0x62,0x21,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x03,
                                0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //36*20
const uint8_t logo_version_pic[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xE0,0xDC,0x9C,
                                0xD8,0xC0,0xC0,0xE8,0xFC,0xDC,0x8C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
                                0x01,0x01,0x00,0x0F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x83,0x80,0x80,0x00,0xC0,0xC0,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,
                                0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x83,0x83,
                                0xBB,0xBC,0xFC,0xFC,0xFC,0xB8,0x83,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0xFF,0xFF,0xC0,0xC0,0xC0,0xFF,0xFF,0xC0,0xC0,0x00,0x00,0xFE,0xFF,0xC3,0xC1,
                                0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0xFF,0x7F,0x60,0x60,0x60,0x60,0xE0,0xC0,0x00,0x00,0x00,
                                0xFF,0xFF,0x0F,0x1C,0x38,0x70,0xE0,0x80,0x00,0x00,0x80,0xE0,0x7C,0x1F,0x01,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,
                                0xFF,0xFF,0x00,0xE0,0xFF,0x07,0x00,0x00,0x80,0xC0,0xE1,0x73,0x3F,0x1E,0x3F,0x71,
                                0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x00,0x00,
                                0x00,0x00,0x00,0x07,0x07,0x03,0x00,0x07,0x07,0x00,0x00,0x07,0x33,0x79,0x78,0x78,
                                0x30,0x80,0xC0,0xE0,0xC0,0x03,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,
                                0x02,0x03,0x03,0x03,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //36*60 版
//镭射图片对象
RaderPic logo_rpp_array[LOGO_PAGE_NUM] = 
{//{pic,x,y,w,h,rd} //镭射图片的成员参数
    {logo_wouo_pic, 4, 8, 49, 20, RD_RIGHT_DOWN},
    {logo_ui_pic, 53, 8, 27, 20, RD_RIGHT_DOWN},
    {logo_page_pic, 20, 36, 36, 20, RD_RIGHT_DOWN},
    {logo_version_pic, 84, 2, 36, 60, RD_RIGHT_DOWN}
};

//设置的列表选项数组
Option setting_option_array[SETTING_PAGE_NUM] = 
{///{ order,max,min,step,int_val,text,} //option的成员顺序
    {.text = "- Setting"}, //第一个做说明标签，没有功能
    {.text = "- UI Setting"},
    {.text = "- UDisk Setting"},
};
Option ui_setting_option_array[UI_SETTING_PAGE_NUM] = 
{///{ order,max,min,step,int_val,text,} //option的成员顺序
    {.text = "- UI Setting"}, //第一个做说明标签，没有功能
    {0, 255, 0, 1, 0, "~ Tile Ani"},
    {0, 255, 0, 1, 0, "~ List Ani"}, //对于数值弹窗，需要给定最大最小值和步长
    {.text = "+ T Ufd Fm Scr", .step = 1,},
    {.text = "+ L Ufd Fm Scr", .step = 1,},
    {.text = "+ T Loop Mode", .step = 1,},
    {.text = "+ L Loop Mode", .step = 1,},
    {.text = "+ ValWin Bok", .step = 1,},
    {.text =  "+ ConWin Bok", .step = 1,},
    {.text =  "$ Dig Ripple", .step = 1,},
    {.text =  "+ RaderPicMode", .step = 1,}, //step为1,能够使用clcik控制取反，为0，则失能取反(通常用于需要外部接管这个变量的情况)
    {0, 10, 1, 1, 0, "~ RP_S_Rate"},
    {0, 100, 0, 1, 0, "~ RP_M_Rate"}, //因为没有办法给初始化的全局变量使用变量值进行初始化，所以int_val暂时先设为0
};
Option udisk_setting_option_array[UDISK_SETTING_PAGE_NUM] = 
{///{ order,max,min,step,int_val,text,} //option的成员顺序
    {.text = "- UDisk Setting"},
    {.text = "$ Oled Inv", .step = 1},
    {.text = "$ Volumn Mode", .step = 1}
};

//Volumn页面的选项
const uint8_t volumn_minus[] = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x01,0x01,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //48*48
const uint8_t volumn_plus[] = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x01,0x01,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const uint8_t volumn_normal [] ={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE,0x00,0x80,0x80,
    0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x20,0x40,
    0xC1,0x81,0x03,0x06,0x0C,0x18,0x30,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x08,0x30,
    0xE0,0x01,0x03,0x0E,0xFC,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x10,0x8C,
    0xC7,0x60,0x30,0x1C,0x0F,0x00,0x80,0xE0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x21,0x20,
    0x30,0x10,0x18,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x01,0x01,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const uint8_t volumn_mute[] = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x60,0xE0,
    0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x60,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
    0x01,0x03,0x07,0x1E,0x38,0xF0,0xC0,0xC0,0xF0,0x38,0x1E,0x07,0x03,0x01,0x00,0x00,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x80,
    0xC0,0x60,0x38,0x1C,0x0E,0x07,0x03,0x03,0x07,0x0E,0x3C,0x70,0xE0,0xC0,0x80,0x00,
    0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x7F,0xFF,
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x03,0x03,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x01,0x01,0x03,0x07,0x07,0x0F,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

//about页面的选项数组
Option about_option_array[ABOUT_PAGE_NUM] = 
{
    {.text = "- About wouo"}, //第一项只是说明
    {.text = "- WouoUI origin"}, //原wououi的说明
    {.text = "- Page version"}, //Page version的说明
};

//about wououi页面的数组
Option about_wououi_option_array[ABOUT_WOUOUI_PAGE_NUM] =
{ //单选项需要以“=”开头
    {.text = "- From WouoUI1.2"},
    {.text = "- Thanks for the "},
    {.text = "  original author"},
    {.text = "- Bilibili UID:"},
    {.text = "= 9182439"},
    {.text = "- Github URL: "},
    {.text = "= https://"},
    {.text = "  github.com/"},
    {.text = "  RQNG/WouoUI"}
};
Option about_pageversion_array[ABOUT_PAGEVERSION_NUM] = 
{
    {.text = "- Page Version"},
    {.text = "- MyBilili UID:"},
    {.text = "= 679703519"},
    {.text = "- Github URL:"},
    {.text = "= https://"},
    {.text = "  github.com/"},
    {.text = "  Sheep118/WouoUI"},
    {.text = "  -PageVersion"},
};
//--------定义每个页面的回调函数

void MainPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order)
    {
        case 0: OLED_UIJumpToPage((PageAddr)cur_page_addr,&logo_page); break;
        case 1: OLED_UIJumpToPage((PageAddr)cur_page_addr,&setting_page);  break;
        case 2: OLED_UIJumpToPage((PageAddr)cur_page_addr,&g_volumn_page); break;
        case 3: OLED_UIJumpToPage((PageAddr)cur_page_addr,&dictionary_page); break;
        case 4: OLED_UIJumpToPage((PageAddr)cur_page_addr,&emotion_page); break;
        case 5: OLED_UIJumpToPage((PageAddr)cur_page_addr,&about_page); break;
        default: break;
    }
}

void SettingPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order)
    {
        case 0: break;
        case 1: OLED_UIJumpToPage((PageAddr)cur_page_addr,&ui_setting_page); break;
        case 2: OLED_UIJumpToPage((PageAddr)cur_page_addr,&udisk_setting_page); break;
        default: break;
    }
}

void UISettingPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order) //对选中项的真实参数值赋值
    { //由于第0项是说明文字“Setting”
        case 1: g_default_ui_para.ani_param[TILE_ANI] = select_item->val;break;//ani_tile
        case 2: g_default_ui_para.ani_param[LIST_ANI] = select_item->val;break;//ani_list
        case 3: g_default_ui_para.ufd_param[TILE_UFD] = select_item->val;break;//ani_tile
        case 4: g_default_ui_para.ufd_param[LIST_UFD] = select_item->val;break;//ani_list
        case 5: g_default_ui_para.loop_param[TILE_UFD] = select_item->val;break;//loop_tile
        case 6: g_default_ui_para.loop_param[LIST_UFD] = select_item->val;break;//loop_list
        case 7: g_default_ui_para.valwin_broken = select_item->val;break;//ValWin Broken
        case 8: g_default_ui_para.conwin_broken = select_item->val;break;//ConWin Broken
        case 9: g_default_ui_para.digital_ripple = select_item->val;break;//Digital Ripple Enable/not
        case 10: g_default_ui_para.raderpic_scan_mode = select_item->val;break;//RaderPic scan mode
        case 11: g_default_ui_para.raderpic_scan_rate = select_item->val;break;//RaderPic scan rate
        case 12: g_default_ui_para.raderpic_move_rate = select_item->val;break;//RaderPic move rate
    default:
      break;
    }
}

void UDiskSettingPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    eDICT_ERR err = eDICT_ERR_OK;
    FRESULT fr = FR_OK;
    uint8_t write_flag = 0; //需要写入文件
    UINT bw;
    if(g_setting_file_array[0]) //只有初始化setting文件存在才能改变
    {
        switch (select_item->order)
        { //oled_inv
            case 1: if(select_item->val != g_setting_file_array[1]) //发生改变
                    {
                        write_flag = 1;
                        g_setting_file_array[1] = select_item->val;
                        if(g_setting_file_array[1] == 1)
                        {
                            OLED_DisplayTurn(1);
                            err = Dict_SetValue(&g_setting_dict, "oled_inv","1");
                        }
                        else{
                            OLED_DisplayTurn(0);
                            err = Dict_SetValue(&g_setting_dict, "oled_inv","0");
                        }
                    }
                break;
            case 2: if(select_item->val != g_setting_file_array[2]) //发生改变
                    {
                        write_flag = 1;
                        g_setting_file_array[2] = select_item->val;
                        if(g_setting_file_array[2] == 1)
                        {
                            err = Dict_SetValue(&g_setting_dict, "volumn_mode","1");
                        }
                        else{
                            err = Dict_SetValue(&g_setting_dict, "volumn_mode","0");
                        }
                    }
                break;
            default: break;
        }
        if(write_flag)
        {
            fr = f_open(&g_setting_file,SETTING_DIR_PATH"/setting.txt",FA_WRITE);
            if(fr == FR_OK)
            {
                err = Dict_Dumps(&g_setting_dict,g_setting_file_buff);
                if(eDICT_ERR_OK == err)
                {
                    f_write(&g_setting_file,g_setting_file_buff,sizeof(g_setting_file_buff)-1, &bw);
                    f_sync(&g_setting_file);
                }
                f_close(&g_setting_file);
            }
            else {g_setting_file_array[0] = 0; } //找不到这个文件的话，标记为0
        }
    }
}

void VolumnPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    static uint8_t volumn_rrect_index = 0; 
    uint8_t volumn_rrect_y_array[5] = {48, 48-8, 48-16, 48-24, 48-32};
    uint8_t volumn_rrect_width_array[5] = {8, 16, 24, 32, 40};
    OLED_SetPointColor(0);
    OLED_WinDrawRBox(&w_all,8,8,48,48,0);
    OLED_SetPointColor(1);
    switch (g_volumn_ctrl_state)
    {
        case 0: // normal
            OLED_WinDrawBMP(&w_all,8,8,48,48,volumn_normal,'|');
            break;
        case 1: 
            OLED_WinDrawBMP(&w_all,8,8,48,48,volumn_mute,'|');
            OLED_SetPointColor(0);
            OLED_WinDrawRBox(&w_all,64,8,48,48,0);
            OLED_SetPointColor(1);
            break;
        case 2:
            OLED_WinDrawBMP(&w_all,8,8,48,48,volumn_plus,'|');
            OLED_WinDrawRBox(&w_all,64,volumn_rrect_y_array[volumn_rrect_index/10],volumn_rrect_width_array[volumn_rrect_index/10],5,2);
            if(volumn_rrect_index == 49){volumn_rrect_index = 0;g_volumn_ctrl_state = 0;}
            volumn_rrect_index++;
            break;
        case 3:
            OLED_WinDrawBMP(&w_all,8,8,48,48,volumn_minus,'|');
            OLED_WinDrawRBox(&w_all,64,volumn_rrect_y_array[4-volumn_rrect_index/10],volumn_rrect_width_array[4-volumn_rrect_index/10],5,1);
            if(volumn_rrect_index == 49){volumn_rrect_index = 0;g_volumn_ctrl_state = 0;}
            volumn_rrect_index++;
            break;
        default: break;
    }
}

void DictionaryPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order)
    {
    }
}

void EmotionPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order)
    {
    }
}


void AboutPage_CallBack(const Page* cur_page_addr,Option* select_item)
{
    switch (select_item->order)
    {//第0项是说明文字
        case 1: OLED_UIJumpToPage((PageAddr)cur_page_addr,&about_wououi_page); break;
        case 2: OLED_UIJumpToPage((PageAddr)cur_page_addr,&about_page_version_page); break;
        default: break;
    }
}


//-------------一些需要用的内部函数


//--------------给主函数调用的接口函数

void TestUI_Init(void)
{
    // OLED_Init();  //硬件的初始化
    HAL_Delay(100);
    OLED_ClearBuff(); //清空缓存
    OLED_RefreshBuff(); //刷新屏幕(清空屏幕)
    OLED_SetPointColor(1); //设置绘制颜色
    //补充列表页面的初值
    ui_setting_option_array[1].val = g_default_ui_para.ani_param[TILE_ANI];
    ui_setting_option_array[2].val = g_default_ui_para.ani_param[LIST_ANI];
    ui_setting_option_array[3].val = g_default_ui_para.ani_param[TILE_UFD];
    ui_setting_option_array[4].val = g_default_ui_para.ani_param[LIST_UFD];
    ui_setting_option_array[5].val = g_default_ui_para.ani_param[TILE_LOOP];
    ui_setting_option_array[6].val = g_default_ui_para.ani_param[LIST_LOOP];
    ui_setting_option_array[7].val = g_default_ui_para.valwin_broken;
    ui_setting_option_array[8].val = g_default_ui_para.conwin_broken;
    ui_setting_option_array[9].val = g_default_ui_para.digital_ripple;
    ui_setting_option_array[10].val = g_default_ui_para.raderpic_scan_mode;
    ui_setting_option_array[11].val = g_default_ui_para.raderpic_scan_rate;
    ui_setting_option_array[12].val = g_default_ui_para.raderpic_move_rate;
    //补充udisk设置页面的初值
    udisk_setting_option_array[1].val = g_setting_file_array[1];
    udisk_setting_option_array[2].val = g_setting_file_array[2];
    //设置界面选项
    OLED_TitlePageInit(&main_page, MAIN_PAGE_NUM, mian_option_array, main_icon_array, MainPage_CallBack);
    OLED_RaderPicPageInit(&logo_page, LOGO_PAGE_NUM, logo_rpp_array,Rader_Pic_Mode_Loop, NULL);
    OLED_ListPageInit(&setting_page, SETTING_PAGE_NUM, setting_option_array, SettingPage_CallBack);
    OLED_ListPageInit(&ui_setting_page,UI_SETTING_PAGE_NUM, ui_setting_option_array, UISettingPage_CallBack);
    OLED_ListPageInit(&udisk_setting_page,UDISK_SETTING_PAGE_NUM, udisk_setting_option_array, UDiskSettingPage_CallBack);
    OLED_RaderPicPageInit(&g_volumn_page,0,NULL,Rader_Pic_Mode_Hold, VolumnPage_CallBack);
    OLED_RaderPicPageInit(&dictionary_page,0,NULL,Rader_Pic_Mode_Hold, DictionaryPage_CallBack);
    OLED_RaderPicPageInit(&emotion_page,0,NULL,Rader_Pic_Mode_Hold, EmotionPage_CallBack);
    OLED_ListPageInit(&about_page, ABOUT_PAGE_NUM, about_option_array, AboutPage_CallBack);
    OLED_RadioPageInit(&about_wououi_page, ABOUT_WOUOUI_PAGE_NUM, about_wououi_option_array, NULL);
    OLED_RadioPageInit(&about_page_version_page, ABOUT_PAGEVERSION_NUM, about_pageversion_array, NULL);
}


void TestUI_Proc(void)
{
    OLED_UIProc();
}

